package com.itstyle.quartz.job;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.apache.commons.lang3.time.FastDateFormat;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class ChickenJob implements  Job,Serializable {


	private static final Logger log = LoggerFactory.getLogger(ChickenJob.class);
	private static final long serialVersionUID = -8871683698022685255L;

	FastDateFormat fdf = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
	SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//设置日期时间格式

	@Override
	public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {





//		System.out.println("大吉大利、今晚吃鸡");
//		Thread thread = new Thread();
		Date date=new Date();

		try{
			log.info("this is my test ChickenJob start");
			Thread.sleep(1000*8);
//			ExecutorService exec = Executors.newFixedThreadPool(1);
//
//			Thread thread = new Thread(new Runnable() {
//				@Override
//				public void run() {
//					log.info("ChickenJob thread start");
//					try {
//						Thread.sleep(1000*30);
//					} catch (InterruptedException e) {
//						// TODO Auto-generated catch block
//						e.printStackTrace();
//					}
//					log.info("ChickenJob thread end");
//				}
//			});
//			exec.execute(thread);
//
//			exec.shutdown();
//			while (!exec.isTerminated()) {
//				// 等待所有子线程结束，才退出主线程
//			}

			log.info("this is my test ChickenJob end for "+df.format(date)+"  "+fdf.format(new Date()));

		}catch (Exception e){

		}
	}
}
